<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="
				 java.util.*,
				 com.kylin.module.shop.orm.*,
                 com.kylin.common.util.*,
				 com.kylin.common.dict.orm.Dict,
                 com.kylin.common.paginate.DisplayPage,
			     com.kylin.module.user.orm.*" %>
<%@ include file="/common/include/pageExpires.jsp"%>
<%@ include file="/common/include/taglibs.jsp"%>

<script type="text/javascript" src="/script/validate.js"></script>
<script type="text/javascript" >
function checkSubmit(){
	var theForm = document.fo1;
    if(theForm.username.value == ""){
        alert("<bean:message key="regcompany.02" />不能为空")
        theForm.username.focus();
        return false;
    }
    if(theForm.name.value == ""){
        alert("<bean:message key="regcompany.03" />不能为空");
        theForm.name.focus();
        return false;
    }
    if( ListIsSelected(theForm.otherLanguages) == false){
        alert("<bean:message key="regcompany.04" />不能为空")
        return false;
    }
    if( ListIsSelected(theForm.mainbusiness) == false){
        alert("<bean:message key="regcompany.05" />不能为空")
        return false;
    }
    if(theForm.username.value.length <3 || theForm.username.value.length > 20){
        alert("用户名要求为 3 到  20 个 字母或数字 ");
        theForm.username.focus();
        return false;
    }
    if(theForm.name.value.length > 100){
        alert("公司名称要求不超过 50 个 汉字");
        theForm.name.focus();
        return false;
    }
	if( 
	   (theForm.phoneCountry.value != "" && !isNumber(theForm.phoneCountry.value))
	 ||(theForm.phoneArea.value!= "" && !isNumber(theForm.phoneArea.value))
	 ||(theForm.phone.value.value != "" && !isNumber(theForm.phone.value)) 
	){
        alert("电话号码要求为数字")
        return false;
	}
	if( 
	   (theForm.faxCountry.value != "" && !isNumber(theForm.faxCountry.value))
	 ||(theForm.faxArea.value!= "" && !isNumber(theForm.faxArea.value))
	 ||(theForm.fax.value.value != "" && !isNumber(theForm.fax.value)) 
	){
        alert("传真号码要求为数字")
        return false;
	}
	
	
    if(theForm.email.value != "" && !isEMail(theForm.email.value) ){
        alert("email 格式错误");
        theForm.email.focus();
        return false;
    }
    return true;
}
</script>

<mytag:MyActionMsg /><br>
<div class="boxtitle"><bean:message key="reg.catcompany" /></div>
<div class="box" style="text-align:center">
<form name="fo1" action="registerCompany.do?CMD=registerCompany" 
    method="post" onsubmit="return checkSubmit()">
<table width="90%"  cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" height="40"><bean:message key="regcompany.01" /></td>
      </tr>
    </table>
    <table width="660"  border="0" cellspacing="2" cellpadding="0">
      <!-- 用户Id -->
        <tr align="left">
          <td><b><bean:message key="regcompany.02" />*：</b></td>
          <td><input name="username" type="text" size="20">
          <input type="submit" name="Submit" value="<bean:message key="base.25" />"></td>
        </tr>
        <!-- 公司名称 -->
        <tr align="left">
          <td width="80"><b><bean:message key="regcompany.03" />*：</b></td>
          <td><input name="name" type="text" size="40"></td>
        </tr>
        <!-- 播放语言 -->
        <tr align="left">
          <td><b><bean:message key="regcompany.04" />：</b></td>
          <td>
      <mytag:national name="otherLanguages" notEmpty="true" size="5" multiple="true" 
                  value="<%= sessionLocale.toString() %>" dictName="<%=Constants.SYSLANGUAGE %>"/>
			</td>
        </tr>
        <!-- 所属国家 -->
        <tr align="left">
          <td><b><bean:message key="base.13" />：</b></td>
          <td>
      			<mytag:national name="country" notEmpty="true" 
                  value="<%= sessionLocale.toString() %>" dictName="<%=Constants.ALLCOUNTRY%>"/>
          </td>
        </tr>
        <!-- 主营行业 -->
        <tr align="left">
          <td><b><bean:message key="regcompany.05" />*:</b></td>
          <td><mytag:select name="mainbusiness" notEmpty="true" multiple="true"
                size="3" dictName="主营业务"/>
			</td>
        </tr>
        <!-- 主营类别 -->
        <tr align="left">
          <td><b><bean:message key="regcompany.06" />:</b></td>
          <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="28%">
              <%
    			  List maincatproduct = MemObjFactory.getDict("产品类别",sessionLocale.toString());
                  StringBuffer sb1 = new StringBuffer();
                  StringBuffer sb2 = new StringBuffer();
                  for(int i=0;i<maincatproduct.size();i++){
                  	  Dict dict = (Dict)maincatproduct.get(i);
                  	  String dictName = dict.getName().replaceAll("'", "`");
                  	  
                      if(dict.getParent() == null){
                          sb1.append("\n<option value='").append(dict.getId()).append("'>");
                          sb1.append(dictName).append("</option>");
                      }else{
                      	 if(sb2.length() > 1)
                      	     sb2.append(",");
                         sb2.append("\n  new SubSelectObj('").append(dict.getId()).append("','");
                         sb2.append(dict.getParent().getId()).append("','");
                         sb2.append(dictName).append("')");
                      }
                  }
              %>
              
              <select name="catproductparent" id="parentSelect" onchange="setSub(this.value)">
              	<%=sb1%>
              </select>
			</td>
            <td width="72%">
             <select name="maincatproduct" id="subSelect" size="4" style="width:100px;" multiple="true">
             </select>
       <script src="/script/kylin.js"></script>
       <script>
		var subArray= new Array(<%=sb2%>); 
		function setSub(pid){
			var subSelcet = document.getElementById("subSelect");
			setSubSelect(subArray,subSelcet,pid);
		}
		setSub(document.getElementById("parentSelect").value);
       </script>       
              </td>
            </tr>
          </table>
</td>
        </tr>
        <tr align="left">
          <td><b><bean:message key="base.26" />：</b></td>
          <td><input name="contact" type="text" size="20"></td>
        </tr>
        <tr align="left">
          <td><b><bean:message key="base.05" />：</b></td>
          <td><input name="phoneCountry" type="text"  size="10">-
            <input name="phoneArea" type="text"  size="10">-
            <input name="phone" type="text"  size="10">-
         <bean:message key="base.08" /></td>
        </tr>
        <!-- 联系电话 -->
        <tr align="left">
          <td><b><bean:message key="base.06" />*：</b></td>
          <td><input name="faxCountry" type="text" size="10">-
              <input name="faxArea" type="text" size="10">-
              <input name="fax" type="text" size="10">
    	<bean:message key="base.09" />*</td>
        </tr>
        <tr align="left">
          <td><b><bean:message key="base.07" />:</b></td>
          <td><input name="email" type="text" size="40">
          <input type="submit" name="Submit" value="<bean:message key="base.27" />"></td>
        </tr>
		<tr align="left">
          <td><b><bean:message key="base.28"/>：</b></td>
          <td><input name="address" type="text" size="40"></td>
        </tr>
        <tr align="left">
          <td><b><bean:message key="base.22"/>:</b></td>
          <td><input name="postcode" type="text" size="20"></td>
        </tr>
        <tr align="left">
        	<td>&nbsp;&nbsp;</td>
          <td height="50" valign="bottom" align="center"><input class="rinput" type="submit" onclick="return checkSubmit()" value=" <bean:message key="community.save"/>" >
			&nbsp;&nbsp;<input class="rinput" type="button" value="取消" onclick="javascript:location.replace('/enter/registerEnter.jsp')"></td>
        </tr>
      </table>
	  <p>&nbsp;</p>
</div>